package gemini.basic.model;
// default package
// Generated Nov 23, 2010 4:23:01 PM by Hibernate Tools 3.4.0.Beta1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

/**
 * Distributor generated by hbm2java
 */
@Entity
@Table(name = "g_distributor", catalog = "gemini", uniqueConstraints = {
		@UniqueConstraint(columnNames = "code") })
public class Distributor extends AbstractDomain implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Integer version;
	private Tab tab;
	private Level level;
	private Distributor distributor;
	private String code;
	private String pin;
	private short discountScale;
	
	private List<Customer> customers = new ArrayList<Customer>(0);
	private List<Event> events = new ArrayList<Event>(0);
	private List<Cart> carts = new ArrayList<Cart>(0);
	private List<Payment> payments = new ArrayList<Payment>(0);
	private List<Distributor> distributors = new ArrayList<Distributor>(0);
	private List<Person> persons = new ArrayList<Person>(0);
	private List<MonthlyPoint> monthlyPoints = new ArrayList<MonthlyPoint>(0);
	private List<DistributorStatus> distributorStatuses = new ArrayList<DistributorStatus>(
			0);

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "tab_id")
	public Tab getTab() {
		return this.tab;
	}

	public void setTab(Tab tab) {
		this.tab = tab;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "level_id", nullable = false)
	public Level getLevel() {
		return this.level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sponsor_id")
	public Distributor getDistributor() {
		return this.distributor;
	}

	public void setDistributor(Distributor distributor) {
		this.distributor = distributor;
	}

	@Column(name = "code", unique = true, nullable = false, length = 20)
	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name = "pin", nullable = false, length = 50)
	public String getPin() {
		return this.pin;
	}

	public void setPin(String pin) {
		this.pin = pin;
	}

	@Column(name = "discount_scale", nullable = false)
	public short getDiscountScale() {
		return this.discountScale;
	}

	public void setDiscountScale(short discountScale) {
		this.discountScale = discountScale;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor", cascade = { CascadeType.ALL })
	public List<DistributorStatus> getDistributorStatuses() {
		return this.distributorStatuses;
	}

	public void setDistributorStatuses(
			List<DistributorStatus> distributorStatuses) {
		this.distributorStatuses = distributorStatuses;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<Cart> getCarts() {
		return this.carts;
	}

	public void setCarts(List<Cart> carts) {
		this.carts = carts;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<Distributor> getDistributors() {
		return this.distributors;
	}

	public void setDistributors(List<Distributor> distributors) {
		this.distributors = distributors;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<Person> getPersons() {
		return this.persons;
	}

	public void setPersons(List<Person> persons) {
		this.persons = persons;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<MonthlyPoint> getMonthlyPoints() {
		return this.monthlyPoints;
	}

	public void setMonthlyPoints(List<MonthlyPoint> monthlyPoints) {
		this.monthlyPoints = monthlyPoints;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<Payment> getPayments() {
		return this.payments;
	}

	public void setPayments(List<Payment> payments) {
		this.payments = payments;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<Customer> getCustomers() {
		return this.customers;
	}

	public void setCustomers(List<Customer> customers) {
		this.customers = customers;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "distributor")
	public List<Event> getEvents() {
		return this.events;
	}

	public void setEvents(List<Event> events) {
		this.events = events;
	}
}
